<template>
  <div class="app-container">
    <!-- banner列表 -->
    <el-table :data="list" stripe style="width: 100%">
      <el-table-column type="index" width="50" label="序号" />
      <el-table-column prop="contractId" align="center" label="合约id" />
      <el-table-column prop="contractName" align="center" label="合约名" />
      <el-table-column prop="contractTxIdList" align="center" label="合约对应操作产生的交易的集合" />
    </el-table>
  </div>
</template>

<script>
import chain from '@/api/chain'

export default {
  data() {
    return {
      list: []
    }
  },
  created() {
    this.findAllChain()
  },
  methods: {
    findAllChain() {
      chain
        .findAllChain()
        .then((response) => {
          const temp = response.data
          for (let i = 0; i < temp.length; i++) {
            temp[i].contractTxIdList = this.arrayToString(temp[i].contractTxIdList)
          }
          this.list = temp
          console.log(response)
        })
        .catch((error) => {
          console.log(error)
        })
    },

    // 将数组变成按照一定格式分隔的string
    arrayToString(array) {
      let res = ''
      for (let index = 0; index < array.length; index++) {
        res += array[index] + '\n'
      }
      console.log(res)
      return res
    }
  }
}
</script>
<style>
.el-table .cell {
  white-space: pre-line;
}
</style>
